package com.bwie.controller;

import com.bwie.common.domain.User;
import com.bwie.common.domain.request.LoginReq;
import com.bwie.common.domain.response.LoginRes;
import com.bwie.common.result.Result;
import com.bwie.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @className: LoginController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 安楷杰
 * @date: 2025/11/4 9:42
 */
@RestController
@CrossOrigin
public class LoginController {
    @Autowired
    private LoginService service;

    /**
     * 登录
     * @param req
     * @return
     */
    @PostMapping("/login")
    public Result<LoginRes> login(@RequestBody LoginReq req) {
        return Result.success(service.login(req));
    }

    /**
     * 手机号发送验证码
     */
    @GetMapping("/sendTel/{phoneNumber}")
    public Result<String> sendTel(@PathVariable(value = "phoneNumber") String phoneNumber){
        service.sendTel(phoneNumber);
        return Result.success("发送成功");
    }

    /**
     * 注册
     */
    @PostMapping("/register")
    public void register(@RequestBody User user) {
        service.lregisterogin(user);
    }
}